import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'

Vue.filter('substring', function(input, length) {
	if (input) {
		if (input.length <= length) {
			return input
		} else {
			return input.substring(0, length) + '...'
		}
	} else {
		return "";
	}
})



// main.js
import uView from "uview-ui";
Vue.use(uView);

import noRecord from './components/no_record.vue'
import popUp from "./components/popUp.vue"

Vue.component('no-record', noRecord)
Vue.component('popUp', popUp)

import config from '@/config.js'
Vue.prototype.$config = config

// 此处为演示vuex使用，非uView的功能部分
import store from '@/store';

let customMixin = require('@/common/custom.mixin.js');
Vue.mixin(customMixin);

// 引入uView提供的对vuex的简写法文件
let vuexStore = require('@/store/$u.mixin.js');
Vue.mixin(vuexStore);

const app = new Vue({
	store,
	...App
})

// http拦截器，此为需要加入的内容，如果不是写在common目录，请自行修改引入路径
import httpInterceptor from '@/common/http/http.interceptor.js'
Vue.use(httpInterceptor, app)

// http接口API集中管理引入部分
import httpApi from '@/common/http/http.api.js'
Vue.use(httpApi, app)

// 过滤器
import * as filters from '@/common/filterTool.js' // global filters
Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key])
})


app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif